package soundwave.com.demo.adpater;

import android.content.Context;
import android.support.annotation.NonNull;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import java.util.ArrayList;

import soundwave.com.demo.R;
import soundwave.com.demo.test.TakeoutfoodGrid_test;

/**
 * Created by xu on 2017/3/30.
 */

public class TakeoutfoodGrid_adapert extends ArrayAdapter<TakeoutfoodGrid_test> {
    private int layoutid;
    private LayoutInflater inflater=null;
    private Context context;
    public TakeoutfoodGrid_adapert(Context context, int resource,ArrayList<TakeoutfoodGrid_test> content) {
        super(context, resource,content);
        this.layoutid=resource;
        this.context=context;


    }

    @NonNull
    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        View view=convertView;
        if (view==null){
            inflater=LayoutInflater.from(context);
            view=inflater.inflate(layoutid,null);
        }
        TakeoutfoodGrid_test takeoutfoodcontent_test=getItem(position);
        ImageView takeoutfood_img= (ImageView) view.findViewById(R.id.takeoutfood_img);
        TextView takeoutfood_name= (TextView) view.findViewById(R.id.takeoutfood_name);
        TextView takeoutfood_money= (TextView) view.findViewById(R.id.takeoutfood_money);

        takeoutfood_img.setImageResource(takeoutfoodcontent_test.getTakeoutfood_img());
        takeoutfood_name.setText(takeoutfoodcontent_test.getTakeoutfood_name());
        takeoutfood_money.setText(String.valueOf(takeoutfoodcontent_test.getTakeoutfood_money()));
        return view;
    }
}
